package pers.zc.activiti.thread;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @description 异步方法
 * @Author Lin FuYuan
 * @date 2020/1/15
 */
@Async
@Component
public class AsyncClas {
    @Autowired
    private CurrentHashMapTest currentHashMapTest;
//    private static volatile Integer n = 0;

    public static void  test(int o){
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
        }
        Integer key = Entity.getInstance().map.get("key");
        if(key == null){
            key = 0;
        }
        Entity.getInstance().map.put("key",key++);

//        Entity instance = Entity.getInstance();
//        int map = instance.getMap();
//        instance.setMap(map++);
        System.out.println("序列: "+o+"   值:  "+key+"  线程: "+Thread.currentThread().getName());

    }
}
